package com.ty.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ty.annotation.Auth;
import com.ty.entity.AfterSales;
import com.ty.resp.CommonResp;
import com.ty.service.IAfterSalesService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 退款表 前端控制器
 * </p>
 *
 * @author txy
 * @since 2024-03-14
 */
@RestController
@RequestMapping("/afterSales")
public class AfterSalesController {
    @Resource
    private IAfterSalesService afterSalesService;

    @GetMapping("/getAfterSales")
    @Auth(roles = "admin,user")
    public CommonResp getAfterSales(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                @RequestParam(value = "size", defaultValue = "3") Integer size,
                                @RequestParam(value = "search", required = false) String search,
                                @RequestParam(value = "userId", required = false) String userId,
                                @RequestParam(value = "status", required = false) Integer status) {
        return afterSalesService.getAfterSales(new Page(page, size), search, userId, status);
    }
    @PostMapping("/createAfterSales")
    @Auth
    public CommonResp createAfterSales(AfterSales afterSales){
        return afterSalesService.createAfterSales(afterSales);
    }
    @PutMapping("/updateAfterSales")
    @Auth(roles = "admin,user")
    public CommonResp updateAfterSales(AfterSales afterSales){
        return afterSalesService.updateAfterSales(afterSales);
    }

}
